package com.tang.factory;

import com.tang.pojo.ScheduleJob;
import com.tang.support.TaskUtils;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author 唐一菲
 * @Description: 若一个方法一次执行不完下次轮转时则等待改方法执行完后才执行下一次操作
 */
//@PersistJobDataAfterExecution 注解时, 当正常执行完Job后, JobDataMap中的数据应该被改动, 以被下一次调用时用，为了避免并发时, 存储数据造成混乱, 强烈建议把@DisallowConcurrentExecution注解也加上。
@DisallowConcurrentExecution // 不允许并发执行 
public class QuartzJobFactoryDisallowConcurrentExecution implements Job {

//	private static final Logger logger = LogManager.getLogger(QuartzJobFactoryDisallowConcurrentExecution.class);

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get("scheduleJob");
        TaskUtils.invokMethod(scheduleJob);

    }
}